package cn.toleo.search.exception;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.servlet.HandlerExceptionResolver;
import org.springframework.web.servlet.ModelAndView;





/**
 * 全局异常处理
 * @author Administrator
 *
 */
public class GlobalExceptionResolver implements HandlerExceptionResolver{
	private static final Logger logger=LoggerFactory.getLogger(GlobalExceptionResolver.class);
	
	@Override
	public ModelAndView resolveException(HttpServletRequest request,HttpServletResponse response,Object handler,Exception e){
		logger.info("进入全局异常处理器lzc==========");
		logger.debug("测试handler的类型"+handler.getClass());
		e.printStackTrace();
		logger.error("系统发生异常lzc============",e);
		//主干
		ModelAndView modelAndView = new ModelAndView();
		modelAndView.addObject("message", "错误见???");
		modelAndView.setViewName("error/exception");
		return modelAndView;
	}
}
